package com.htgd.gardenexpo.dao;

import com.htgd.gardenexpo.entity.GeConDailyDataDeck;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.htgd.gardenexpo.vo.MileageDurationTrackVO;
import com.htgd.gardenexpo.vo.MyDailyDataDeckSportsRecordVO;
import com.htgd.gardenexpo.vo.MySportsRecordVO;
import com.htgd.gardenexpo.vo.MyTaskDetails;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 日常甲板数据 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2025-04-03
 */
public interface GeConDailyDataDeckMapper extends BaseMapper<GeConDailyDataDeck> {
    @Select("SELECT COALESCE(SUM(mileage), 0) FROM `ge_con_daily_data_deck` WHERE deck_id =#{deckId}")
    double getSumMileageByDeckId(@Param("deckId") String deckId);
    @Select("SELECT COALESCE(SUM(duration), 0) FROM `ge_con_daily_data_deck` WHERE deck_id =#{deckId}")
    long getSumDurationByDeckId(@Param("deckId") String deckId);
    @Select("SELECT COALESCE(SUM(mileage), 0) FROM `ge_con_daily_data_deck` WHERE deck_id =#{deckId} and begin_time like CONCAT(#{date},'%')")
    double getSumMileageByDeckIdAndDate(@Param("deckId")String deckId, @Param("date") String date);
    @Select("SELECT COALESCE(SUM(duration), 0) FROM `ge_con_daily_data_deck` WHERE deck_id =#{deckId} and begin_time like CONCAT(#{date},'%')")
    long getSumDurationByDeckIdAndDate(@Param("deckId")String deckId, @Param("date") String date);

    List<MyDailyDataDeckSportsRecordVO> getMySportsRecord(@Param("deckId") String deckId);

    List<MySportsRecordVO> getSportsRecord(@Param("deckId") String deckId);
@Select("SELECT * FROM `ge_con_daily_data_deck` WHERE task_id = #{taskId} ORDER BY end_time DESC LIMIT 1")
    GeConDailyDataDeck getEndRecord(@Param("taskId") String taskId);

    MileageDurationTrackVO getDataByTaskId(@Param("taskId") String taskId);

    List<String> getTracksByDeckIdAndDate(@Param("deckId")String deckId, @Param("date") String date);

    MyTaskDetails getTaskDetails(@Param("taskId") String taskId);
}
